package com.pearadmin.pro.modules.recruit.rest;

import com.pearadmin.pro.modules.recruit.domain.ScrmSysRecruit;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.recruit.domain.ScrmSysRecruit;
import  com.pearadmin.pro.modules.recruit.param.ScrmSysRecruitRequest;
import  com.pearadmin.pro.modules.recruit.service.ScrmSysRecruitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 招聘信息Controller
 *
 * @author chenJian
 * @date 2021-10-07
 */
@Api(tags = {"招聘信息"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"recruit/sysRecruit")
public class ScrmSysRecruitController extends BaseController
{
    @Resource
    private ScrmSysRecruitService scrmSysRecruitService;

    /**
     * 查询招聘信息列表
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "招聘信息列表")
    @ApiOperation(value = "招聘信息列表")
    public Result<ScrmSysRecruit> list(ScrmSysRecruitRequest scrmSysRecruitRequest)
    {
        return success(scrmSysRecruitService.page(scrmSysRecruitRequest));
    }


    /**
     * 新增保存招聘信息
     * @param scrmSysRecruit 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增招聘信息")
    @ApiOperation(value = "新增招聘信息")
    public Result save(@RequestBody ScrmSysRecruit scrmSysRecruit)
    {
        return auto(scrmSysRecruitService.saveOrUpdate(scrmSysRecruit));
    }

    /**
     * 查询招聘信息详情
     *
     * @param id 招聘信息ID
     * @return 招聘信息
     */
    @GetMapping("/selectById")
    @Log(title = "查询招聘信息详情")
    @ApiOperation(value = "查询招聘信息详情")
    public Result<ScrmSysRecruit> selectById(@RequestParam Long id)
    {
        return success(scrmSysRecruitService.selectScrmSysRecruitById(id));
    }



    /**
     * 修改保存招聘信息
     * @param scrmSysRecruit 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改招聘信息")
    @ApiOperation(value = "修改招聘信息")
    public Result update(@RequestBody ScrmSysRecruit scrmSysRecruit)
    {
        return auto(scrmSysRecruitService.saveOrUpdate(scrmSysRecruit));
    }


    /**
     * 删除保存招聘信息
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除招聘信息")
    @ApiOperation(value = "删除招聘信息")
    public Result remove(@RequestParam Long id)
    {
        return auto(scrmSysRecruitService.removeById(id));
    }

    /**
    * 批量删除招聘信息
    * @param ids 批量删除
    * @return {@link Result}
    */
    @DeleteMapping("removeBatch")
    @Log(title = "批量删除招聘信息")
    @ApiOperation(value = "批量删除招聘信息")
    public Result removeBatch(@RequestParam List<Long> ids){
        return auto(scrmSysRecruitService.removeByIds(ids));
    }

}
